#include "isSubTree.h"
bool doJudge(TreeNode* root1, TreeNode* root2)
{
    if (!root1 && root2)
        return false;
    if (root1 && !root2)
        return false;
    if (!root2 && !root1)
        return true;
    if (abs(root1->val - root2->val) > 1e-4)
        return false;
    else
        return doJudge(root1->left, root2->left) && doJudge(root1->right, root2->right);
}
bool isSubTree(TreeNode* root1, TreeNode* root2)
{
    if (!root2)
        return true;
    if (!root1 && root2)
        return false;
    else
    {
        if (doJudge(root1, root2))
            return true;
        else
            return isSubTree(root1->left, root2) || isSubTree(root1->right, root2);
    }
}